import { FormRule, Image, PrimaryTableCol } from 'tdesign-vue-next';

/**
 * 搜索表单项
 */
export const getSearchParams = () => [
  {
    label: '药膳名称',
    key: 'name',
    hide: false,
  },
];

/**
 * 表格列
 */
export const getColumns = (): PrimaryTableCol[] => [
  {
    title: '药膳名称',
    ellipsis: true,
    align: 'center',
    colKey: 'name',
  },
  {
    title: '图片',
    align: 'center',
    colKey: 'cover',
    cell: (h, { row }) =>
      h(Image, { src: row.cover, fit: 'contain', style: 'width: 100px; height: 100px;margin: 0 auto' }),
  },
  {
    title: '简介',
    ellipsis: true,
    align: 'center',
    colKey: 'introduction',
  },
];

/**
 * 表单校验规则
 */
export const getRules = (): Record<string, FormRule[]> => ({
  name: [{ required: true, message: '请输入药膳', type: 'error', trigger: 'blur' }],
});
